import {reqGoodsNav,reqGoodsList} from '@/api/api'

const actions = {
  // 获取商品导航信息
  async getGoodsNav(context){
    const res = await reqGoodsNav()
    if(res.code === 200){
      context.commit("GETGOODSNAV",res.data)
    }
  },
  // 获取简单商品信息
  async getGoodsList(context,id){
    const res = await reqGoodsList(id)
    if(res.code === 200){
      context.commit("GETGOODSLIST",res.data)
    }
  }
}

const mutations = {
  GETGOODSNAV(state,data){
    state.goodsNav = data
  },
  GETGOODSLIST(state,data){
    state.goodsList = data.list
  }
}

const state = {
  goodsNav:[],
  goodsList:[]
}

const getters = {

}

export default {
  namespaced:true,
  state,
  actions,
  mutations,
  getters
}